package com.org.api.support.config;

import com.org.api.support.interceptors.AdminApiInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author duheng
 * @Date 2021/11/13 17:09
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

	private static final String[] adminApiInterceptorPatterns = {"/api/admin/**"};

	private static final String[] adminApiInterceptorExcludePatterns = {"/api/admin/user/login", "/api/admin/test/**"};

	@Autowired
	private AdminApiInterceptor adminApiInterceptor;

	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		registry.addInterceptor(adminApiInterceptor).addPathPatterns(adminApiInterceptorPatterns).excludePathPatterns(adminApiInterceptorExcludePatterns);
	}

}
